package com.better.frontend.controller.grade;

import com.better.common.base.ServiceResponse;
import com.better.common.utils.CmsHttpPostUtil;
import com.better.frontend.Iservice.studentScore.StudentScoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * @author tangping
 */
@Api(value = "根据年级id获得对应数据", tags = "根据年级id获得对应数据")
@RestController
@RequestMapping("/api/grade")
public class GradeController {
    @Value("${classListUrl}")
    private String classListUrl;
    @Value("${subjectUrl}")
    private String subjectUrl;
    @Value("${knowledgeUrl}")
    private String knowledgeUrl;
    @Value("${gradeUrl}")
    private String gradeUrl;
    @Resource
    private StudentScoreService studentScoreService;

    /**
     * @param gradeId
     * @return
     */
    @ApiOperation(value = "根据年级id获得所有的班级信息", notes = "根据年级id获得所有的班级信息传入年级id")
    @GetMapping("getClassListByGradeId")
    public ServiceResponse getClassListByGradeId(String gradeId) {
        return CmsHttpPostUtil.HttpsGet(classListUrl + gradeId, new HashMap<>(16));
    }

    /**
     * @param gradeId
     * @return
     */
    @ApiOperation(value = "根据年级id获得所有的科目信息", notes = "根据年级id获得所有的科目信息传入年级id")
    @GetMapping("getSubjectByGradeId")
    public ServiceResponse getSubjectByGradeId(String gradeId) {
        return CmsHttpPostUtil.HttpsGet(subjectUrl + gradeId, new HashMap<>(16));
    }

    /**
     * @param subjectId
     * @return
     */
    @ApiOperation(value = "根据科目id获得所有的知识点信息", notes = "根据科目id获得所有的知识点信息传入科目id")
    @GetMapping("getKnowledgeBySubjectId")
    public ServiceResponse getKnowledgeBySubjectId(String subjectId) {
        return CmsHttpPostUtil.HttpsGet(knowledgeUrl + subjectId, new HashMap<>(16));
    }

    /**
     * @param schoolId
     * @return
     */
    @ApiOperation(value = "根据学校id获得所有的年级信息", notes = "根据学校id获得所有的年级信息")
    @GetMapping("getGradeListBySchoolId")
    public ServiceResponse getGradeListBySchoolId(String schoolId) {
        return CmsHttpPostUtil.HttpsGet(gradeUrl + schoolId, new HashMap<>(16));
    }

    /**
     *  使用考试id获得信息
     * @param examId
     * @return
     */
    @ApiOperation(value = "根据考试id获得必要数据", notes = "根据考试id获得必要数据")
    @GetMapping("getItemsByExamId")
    public ServiceResponse getItemsByExamId(String examId){
        return this.studentScoreService.getItemsByExamId(examId);
    }

}
